//
//  MsgIsReadViewController.h
//  daogouApp
//
//  Created by panquanReabam.com on 15/7/9.
//  Copyright (c) 2015年 jiezsoft.com. All rights reserved.

#import "NoticeListViewController.h"
#import "myNewsCell.h"
#import "HAODEsingleton.h"
#import "UIViewExt.h"
#import "RDVTabBarController.h"
#import "HttpRequest.h"
#import "JSONKit.h"
#import "UIButton+WebCache.h"

#import "NoticeDetailViewController.h"
#import "TheLoginViewController.h"
#import "MJRefresh.h"

@interface NoticeListViewController ()<MBProgressHUDDelegate,UIGestureRecognizerDelegate,UINavigationControllerDelegate,UITextFieldDelegate>


@end

@implementation NoticeListViewController

{
    UISearchBar *search;
    HAODEsingleton* commdity;
    MJRefreshHeaderView* _header;
    MJRefreshFooterView* _footer;
    NSMutableArray*Title;
    NSMutableArray*Content;
    NSMutableArray*Area;
    NSMutableArray*fid;
    NSMutableArray*groupName;
    NSMutableArray*IsRead;
    NSMutableArray*pigrade;
    NSMutableArray* ImageHeigh;
    NSMutableArray* ImageWidth;
    NSMutableArray* piname;
    NSMutableArray* pititle;
    NSMutableArray* pubTime;
    int pageNumber;
    NSString*TotalCount;
}
@synthesize alt = alt;


#pragma mark - TextField delegate


-(void)BackAction:(UIButton *)sender{
    
    
    [self.navigationController popViewControllerAnimated:YES];
    
}
- (void)viewDidDisappear:(BOOL)animated

{
    
    [super viewDidDisappear:animated];
    
    
    
    self.navigationController.delegate = nil;
    
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [[self rdv_tabBarController] setTabBarHidden:YES];
    self.navigationController.navigationBarHidden = NO;
        self.navigationController.navigationBar.barStyle = UIBaselineAdjustmentNone;
    UILabel *lineLabel=[[UILabel alloc] initWithFrame:CGRectMake(0, 43,ScreenWidth, 1)];
    [lineLabel setBackgroundColor:[UIColor colorWithRed:238.0/255.0 green:238.0/255.0 blue:238.0/255.0 alpha:1.0]];
    [self.navigationController.navigationBar addSubview:lineLabel];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    [[UINavigationBar appearance] setBarTintColor:Color];
    
       UIImage* backImage = [UIImage imageNamed:@"fanhui"];
    CGRect backframe = CGRectMake(0,0,30,30);
    UIButton* backButton= [[UIButton alloc] initWithFrame:backframe];
    [backButton setBackgroundImage:backImage forState:UIControlStateNormal];
    backButton.titleLabel.font=[UIFont systemFontOfSize:13];
    [backButton addTarget:self action:@selector(BackAction:) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem* leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
    self.navigationItem.leftBarButtonItem = leftBarButtonItem;
    
    
    self.navigationController.delegate = self;
    self.navigationController.interactivePopGestureRecognizer.enabled = YES;
    self.navigationController.interactivePopGestureRecognizer.delegate = self;
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@""] forBarMetrics:UIBarMetricsDefault];
    self.navigationController.navigationBar.shadowImage =[[UIImage alloc] init];
    
    [Global showIndeterminateHud:@"获取数据，请稍后.." delay:30 view:self.view];
    [self add];
}

- (void)viewDidLoad
{
    
    [super viewDidLoad];
    
    [self addFooter];
    
    [self addheader];
}
-(void)add{
    pageNumber=1;
    fid = [[NSMutableArray alloc] init];
    groupName = [[NSMutableArray alloc] init];
    pigrade = [[NSMutableArray alloc] init];
    IsRead= [[NSMutableArray alloc] init];
    piname=[[NSMutableArray alloc] init];
    pititle = [[NSMutableArray alloc] init];
    ImageHeigh = [[NSMutableArray alloc] init];
    ImageWidth = [[NSMutableArray alloc] init];
    pubTime= [[NSMutableArray alloc] init];
    self.title=@"物业通告";
    [self.navigationController.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                                                     [UIColor blackColor],
                                                                     UITextAttributeTextColor,
                                                                     [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1],
                                                                     UITextAttributeTextShadowColor,
                                                                     [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
                                                                     UITextAttributeTextShadowOffset,
                                                                     [UIFont fontWithName:@"Helvetica Neue" size:tetlefot],
                                                                     UITextAttributeFont,nil]];
    
    
    _table.delegate=self;
    _table.dataSource=self;
    _table.separatorStyle=UITableViewCellSeparatorStyleNone;
    commdity=[HAODEsingleton shared];
    
    
    
    
    
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
    [param setValue:@"1" forKey:@"pageIndex"];
    [param setValue:@"20" forKey:@"pageSize"];
    
    NSLog(@"====%@",param);
    [HttpRequest requestData:@"/Estate/Notice/List" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"33333333====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                TotalCount=[severDataDict.dataDict objectForKey:@"TotalCount"];
                NSMutableArray* arrr=[[NSMutableArray alloc]init];
                NSString*ResultInt=[severDataDict.dataDict objectForKey:@"ResultInt"];
                arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
          
            
                UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
                
                view.backgroundColor=zuiqianhuicolor;
                _table.tableHeaderView=view;
                
                UILabel* duoshao=[[UILabel alloc]initWithFrame:CGRectMake(20, 25/2, 200, 15)];
                duoshao.text=[NSString stringWithFormat:@"共有 %@ 条新信息",[severDataDict.dataDict objectForKey:@"nReadCount"]];
                duoshao.font=[UIFont systemFontOfSize:15];
                duoshao.textColor=zhonghuiColor;
                
                NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"共有  %@  条新信息",[severDataDict.dataDict objectForKey:@"nReadCount"]]];
                
                [AttributedStr addAttribute:NSFontAttributeName
                 
                                      value:[UIFont systemFontOfSize:15]
                 
                                      range:NSMakeRange(2, 4)];
                
                [AttributedStr addAttribute:NSForegroundColorAttributeName
                 
                                      value:shenhongsecolor
                 
                                      range:NSMakeRange(2, 4)];
                
                
                duoshao.attributedText = AttributedStr;

                 [view addSubview:duoshao];
                
                
                
                
//                UIButton*shaixuanBtn=[[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth*590/750,  ScreenHeight*12/1334, ScreenWidth*140/750,ScreenWidth*50/750)];
//                [shaixuanBtn.layer setCornerRadius:2.0];
//                [shaixuanBtn.layer setBorderWidth:0.5];
//                [shaixuanBtn.layer setMasksToBounds:YES];
//                [shaixuanBtn addTarget:self action:@selector(addhuiyuan:) forControlEvents:UIControlEventTouchUpInside];
//                CGColorSpaceRef colorSpace2 = CGColorSpaceCreateDeviceRGB();
//                CGColorRef colorref2 = CGColorCreate(colorSpace2,(CGFloat[]){153/255.0,153/255.0, 153/255.0, 1.0   });
//                [shaixuanBtn.layer setBorderColor:colorref2];//边框颜色
//                [shaixuanBtn setTitle:@"全部已读" forState:UIControlStateNormal];
//                shaixuanBtn.titleLabel.font=[UIFont systemFontOfSize:contenfot];
//                [shaixuanBtn setTitleColor:shenhuicolor forState:UIControlStateNormal];
//                shaixuanBtn.titleLabel.textAlignment=NSTextAlignmentRight;
//                [view addSubview:shaixuanBtn];
                
                
                if (ResultInt.intValue==0) {
                    [Global hideProgressHUDInternal:self.view];
                    
                    
                    if (TotalCount.intValue==0) {
                        UILabel* noLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 17)];
                        noLabel.text=@"无数据";
                        noLabel.textColor=[UIColor blackColor];
                        noLabel.textAlignment=NSTextAlignmentCenter;
                        noLabel.center=self.view.center;
                        [self.view addSubview:noLabel];
                        
                    }else{
                        
                        for (NSDictionary* dicc in arrr )
                        {
                            [piname addObject:[dicc valueForKey:@"piname"]];
                            [pititle addObject:[dicc valueForKey:@"pititle"]];
                            [IsRead addObject:[dicc valueForKey:@"isRead"]];
                            [fid addObject:[dicc valueForKey:@"fid"]];
                            [pigrade addObject:[dicc valueForKey:@"pigrade"]];
                            [groupName addObject:[dicc valueForKey:@"groupName"]];
                            //
//                            NSString* string =  [dicc valueForKey:@"pubTime"];
//                            NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//                            [dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss "];
//                            NSDate *destDate= [dateFormatter dateFromString:string];
//                            
//                            NSTimeInterval  timeInterval = [destDate timeIntervalSinceNow];
//                            timeInterval = -timeInterval;
//                            
//                            
//                            
//                            
//                            
//                            long temp = 0;
//                            NSString *result;
//                            if (timeInterval < 60) {
//                                result = [NSString stringWithFormat:@"刚刚"];
//                            }
//                            else if((temp = timeInterval/60) <60){
//                                result = [NSString stringWithFormat:@"%ld分前",temp];
//                            }
//                            
//                            else if((temp = temp/60) <24){
//                                result = [NSString stringWithFormat:@"%ld小时前",temp];
//                            }
//                            
//                            else if((temp = temp/24) <30){
//                                result = [NSString stringWithFormat:@"%ld天前",temp];
//                            }
//                            
//                            else if((temp = temp/30) <12){
//                                result = [NSString stringWithFormat:@"%ld月前",temp];
//                            }
//                            else{
//                                temp = temp/12;
//                                result = [NSString stringWithFormat:@"%ld年前",temp];
//                            }
//                            
                            
                            [pubTime addObject: [dicc valueForKey:@"pubTime"]];
                            
                            
                            
                        }
                        
                       
                    }
                }
                
                [_table reloadData];
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                // [Global showTextHud:requestResultStr view:self.view];
                [Global showTextHudSub:requestResultStr view:self.view];
                
                
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHud:requestResultStr view:self.view];
                    
                    TheLoginViewController*vc1=[[TheLoginViewController alloc] init];
                    
                    [self.navigationController pushViewController:vc1 animated:YES];
                    
                    
                    
                }
            }
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
}





//下拉刷新
- (void)addheader
{
    
    //
    
    
    
    MJRefreshHeaderView* footer = [MJRefreshHeaderView header];
    footer.scrollView = _table;
    footer.beginRefreshingBlock = ^(MJRefreshBaseView* refreshView)
    {
        
        //        self.sats=@"newOrder";
        
              [self add];
        
        
        [self performSelector:@selector(doneWithView:) withObject:refreshView afterDelay:3.0f];
        NSLog(@"%@--->正在刷新", refreshView.class);
    };
}



//上拉刷新
- (void)addFooter
{
    
    
    MJRefreshFooterView* footer = [MJRefreshFooterView footer];
    footer.scrollView = _table;
    footer.beginRefreshingBlock = ^(MJRefreshBaseView* refreshView)
    {
        
        
        
        
        
        NSLog(@"---------%d",pageNumber);
        NSLog(@"++++%d",TotalCount.intValue/5);
        
        
        if (TotalCount.intValue/20>=pageNumber) {
            pageNumber++;
            NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
            NSString* Token = [user objectForKey:@"tokenId"];
            if (Token ==nil) {
                Token=@"dd";
            }
            NSMutableDictionary *param = [NSMutableDictionary new];
            [param setValue:Token forKey:@"tokenId"];
            [param setValue:[NSString stringWithFormat:@"%d" ,pageNumber] forKey:@"pageIndex"];
            [param setValue:@"20" forKey:@"pageSize"];
            
            NSLog(@"====%@",param);
            [HttpRequest requestData:@"/Estate/Notice/List" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
                if (isSuccess) {
                    
                    NSLog(@"33333333====%@",severDataDict.dataDict);
                    if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                        [Global hideProgressHUDInternal:self.view];
                        TotalCount=[severDataDict.dataDict objectForKey:@"TotalCount"];
                        NSMutableArray* arrr=[[NSMutableArray alloc]init];
                        NSString*ResultInt=[severDataDict.dataDict objectForKey:@"ResultInt"];
                        arrr=[severDataDict.dataDict objectForKey:@"DataLine"];
                 
                        
                        UIView*view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 40)];
                        
                        view.backgroundColor=zuiqianhuicolor;
                        _table.tableHeaderView=view;
                        
                        UILabel* duoshao=[[UILabel alloc]initWithFrame:CGRectMake(20, 25/2, 200, 15)];
                        duoshao.text=[NSString stringWithFormat:@"共有 %@ 条新信息",[severDataDict.dataDict objectForKey:@"TotalCount"]];
                        duoshao.font=[UIFont systemFontOfSize:15];
                        duoshao.textColor=zhonghuiColor;
                        
                        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"共有  %@  条新信息",[severDataDict.dataDict objectForKey:@"TotalCount"]]];
                        
                        [AttributedStr addAttribute:NSFontAttributeName
                         
                                              value:[UIFont systemFontOfSize:15]
                         
                                              range:NSMakeRange(2, 4)];
                        
                        [AttributedStr addAttribute:NSForegroundColorAttributeName
                         
                                              value:shenhongsecolor
                         
                                              range:NSMakeRange(2, 4)];
                        
                        
                        duoshao.attributedText = AttributedStr;
                        
                        [view addSubview:duoshao];
                        
                 
                        
                        if (ResultInt.intValue==0) {
                            [Global hideProgressHUDInternal:self.view];
                            
                            
                            if (TotalCount.intValue==0) {
                                UILabel* noLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 17)];
                                noLabel.text=@"无数据";
                                noLabel.textColor=[UIColor blackColor];
                                noLabel.textAlignment=NSTextAlignmentCenter;
                                noLabel.center=self.view.center;
                                [self.view addSubview:noLabel];
                                
                            }else{
                                
                                for (NSDictionary* dicc in arrr )
                                {
                                    [piname addObject:[dicc valueForKey:@"piname"]];
                                    [pititle addObject:[dicc valueForKey:@"pititle"]];
                                    [IsRead addObject:[dicc valueForKey:@"isRead"]];
                                    [fid addObject:[dicc valueForKey:@"fid"]];
                                    [pigrade addObject:[dicc valueForKey:@"pigrade"]];
                                    [groupName addObject:[dicc valueForKey:@"groupName"]];
//                                    //
//                                    NSString* string =  [dicc valueForKey:@"pubTime"];
//                                    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//                                    [dateFormatter setDateFormat: @"yyyy-MM-dd HH:mm:ss "];
//                                    NSDate *destDate= [dateFormatter dateFromString:string];
//                                    
//                                    NSTimeInterval  timeInterval = [destDate timeIntervalSinceNow];
//                                    timeInterval = -timeInterval;
//                                    
//                                    
//                                    
//                                    
//                                    
//                                    long temp = 0;
//                                    NSString *result;
//                                    if (timeInterval < 60) {
//                                        result = [NSString stringWithFormat:@"刚刚"];
//                                    }
//                                    else if((temp = timeInterval/60) <60){
//                                        result = [NSString stringWithFormat:@"%ld分前",temp];
//                                    }
//                                    
//                                    else if((temp = temp/60) <24){
//                                        result = [NSString stringWithFormat:@"%ld小时前",temp];
//                                    }
//                                    
//                                    else if((temp = temp/24) <30){
//                                        result = [NSString stringWithFormat:@"%ld天前",temp];
//                                    }
//                                    
//                                    else if((temp = temp/30) <12){
//                                        result = [NSString stringWithFormat:@"%ld月前",temp];
//                                    }
//                                    else{
//                                        temp = temp/12;
//                                        result = [NSString stringWithFormat:@"%ld年前",temp];
//                                    }
                                    
                                    
                                    [pubTime addObject:[dicc valueForKey:@"pubTime"]];
                                    
                                    
                                    
                                }
                                
                                
                            }
                        }
                        
                        [_table reloadData];
                    }else{
                        [Global hideProgressHUDInternal:self.view];
                        NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                        // [Global showTextHud:requestResultStr view:self.view];
                        [Global showTextHudSub:requestResultStr view:self.view];
                        
                        
                        if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                            
                            NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                            [Global showTextHud:requestResultStr view:self.view];
                            
                            TheLoginViewController*vc1=[[TheLoginViewController alloc] init];
                            
                            [self.navigationController pushViewController:vc1 animated:YES];
                            
                            
                            
                        }
                    }
                }
                else
                {
                    [Global hideProgressHUDInternal:self.view];
                    
                    [Global showTextHudSub:@"连接失败" view:self.view];
                }
                
            }];
            
        }else{
            
            NSString *requestResultStr=@"没有更多数据了！";
            // [Global showTextHud:requestResultStr view:self.view];
            [Global showTextHudSub:requestResultStr view:self.view];
            
            
        }
        
        
        
        
        
        
        [self performSelector:@selector(doneWithView:) withObject:refreshView afterDelay:3.0f];
        NSLog(@"%@--->正在刷新", refreshView.class);
    };
}
- (void)doneWithView:(MJRefreshBaseView *)refreshView
{
    [_table reloadData];
    [refreshView endRefreshing];
}


- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [fid count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    
    myNewsCell* cell = (myNewsCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        NSArray* nib = [[NSBundle mainBundle] loadNibNamed:@"myNewsCell" owner:self options:nil];
        cell = [nib objectAtIndex:0];
    }
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    if ([[IsRead objectAtIndex:indexPath.row]isEqualToString:@"N"]) {
        cell.dian=[[UIButton alloc]initWithFrame:CGRectMake(15, 23, 10, 10)];
        cell.dian.backgroundColor=[UIColor colorWithRed:229.00/255.00 green:19/255.00 blue:19/255.00 alpha:1.0];
        cell.dian.layer.masksToBounds = YES;
        cell.dian.layer.cornerRadius = 5;
        cell.dian.layer.borderColor = [UIColor whiteColor].CGColor;
        cell.dian.layer.borderWidth = 0;
        cell.dian.contentHorizontalAlignment = UIControlContentHorizontalAlignmentFill;
        
        [cell.contentView addSubview:  cell.dian];
        cell.name.text=[NSString stringWithFormat:@"%@",[piname objectAtIndex:indexPath.row]];
        cell.name.textColor=[UIColor blackColor];
        cell.name .frame=CGRectMake(30, 20, ScreenWidth-50, 17);
        cell.name .font=[UIFont systemFontOfSize:17];
        
        
        
        NSString *s2 = [pititle objectAtIndex:indexPath.row];
        
        cell.text.frame=CGRectMake(30, 45, ScreenWidth-40,40);
        cell.text.text = [NSString stringWithFormat:@"尊敬的业主/住户: %@", s2];
        cell.text.numberOfLines =2;
        cell.text.font = [UIFont systemFontOfSize:15];
        [cell.text setTextColor:shenhuicolor];
        NSMutableAttributedString *AttributedStr = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"尊敬的业主/住户: %@",[pititle objectAtIndex:indexPath.row]]];
        
        [AttributedStr addAttribute:NSFontAttributeName
         
                              value:[UIFont systemFontOfSize:15]
         
                              range:NSMakeRange(0, 9)];
        
        [AttributedStr addAttribute:NSForegroundColorAttributeName
         
                              value:luseColor
         
                              range:NSMakeRange(0, 9)];
        
        
          cell.text.attributedText = AttributedStr;

        NSRange range={0,10};
        NSString* string =[[pubTime objectAtIndex:indexPath.row] substringWithRange:range];
        cell.time.text=[NSString stringWithFormat:@" %@ %@",[groupName objectAtIndex:indexPath.row],string];
        cell.time.textColor=shenhuicolor;
        cell.time .frame=CGRectMake(ScreenWidth-180,  cell.text.bottom+10, 160, 14);
        cell.time.textAlignment=NSTextAlignmentRight;
        cell.time .font=[UIFont systemFontOfSize:14];
        
        
    }else{
        
        cell.name.text=[NSString stringWithFormat:@"%@",[piname objectAtIndex:indexPath.row]];
        cell.name.textColor=zhonghuiColor;
        cell.name .frame=CGRectMake(30, 20, ScreenWidth-50, 17);
        cell.name .font=[UIFont systemFontOfSize:17];
        
        NSString *s2 = [pititle objectAtIndex:indexPath.row];
      
        cell.text.frame=CGRectMake(30, 45, ScreenWidth-40,40);
        cell.text.text = [NSString stringWithFormat:@"尊敬的业主/住户: %@", s2];
        cell.text.numberOfLines = 0;
        cell.text.font = [UIFont systemFontOfSize:44/3];
        [cell.text setTextColor:zhonghuiColor];
        
        NSRange range={0,10};
        NSString* string =[[pubTime objectAtIndex:indexPath.row] substringWithRange:range];
        cell.time.text=[NSString stringWithFormat:@" %@ %@",[groupName objectAtIndex:indexPath.row],string];
        cell.time.textColor=zhonghuiColor;
        cell.time .frame=CGRectMake(ScreenWidth-180,  cell.text.bottom+10, 160, 14);
        cell.time.textAlignment=NSTextAlignmentRight;
        cell.time .font=[UIFont systemFontOfSize:14];

        
        
        
        
    }
    
    
    
    
    if (pititle.count !=indexPath.row+1) {
        UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(20,  120-0.3, ScreenWidth-40, 0.3)];
        lineLabel1.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel1];
        
    }
    
    if (pititle.count ==indexPath.row+1) {
        UILabel *lineLabel1=[[UILabel alloc] initWithFrame:CGRectMake(0, 120-0.3, ScreenWidth, 0.3)];
        lineLabel1.backgroundColor=qianhuicolor;
        [cell.contentView addSubview:lineLabel1];
        
    }
    
    
    
    return cell;
}

- (CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 120;
    
    
}


#pragma mark - Table view delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSUserDefaults *user = [NSUserDefaults standardUserDefaults];
    NSString* Token = [user objectForKey:@"tokenId"];
    if (Token ==nil) {
        Token=@"dd";
    }
    NSMutableDictionary *param = [NSMutableDictionary new];
    [param setValue:Token forKey:@"tokenId"];
   
    [param setValue:fid[indexPath.row] forKey:@"noticeId"];
    
    
    NSLog(@"====%@",param);
    
    
    [HttpRequest requestData:@"/Estate/Notice/Read" params:param success:^(BOOL isSuccess, SeverData *severDataDict) {
        if (isSuccess) {
            
            NSLog(@"33333333====%@",severDataDict.dataDict);
            if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==0) {
                [Global hideProgressHUDInternal:self.view];
                
                
                commdity.orderId=fid[indexPath.row];
                NoticeDetailViewController*vc1=[[NoticeDetailViewController alloc] init];
                
                [self.navigationController pushViewController:vc1 animated:YES];
                
                
            }else{
                [Global hideProgressHUDInternal:self.view];
                NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                // [Global showTextHud:requestResultStr view:self.view];
                [Global showTextHudSub:requestResultStr view:self.view];
                
                
                if ([[severDataDict.dataDict objectForKey:@"ResultInt"] integerValue]==9999) {
                    
                    NSString *requestResultStr=[severDataDict.dataDict objectForKey:@"ResultString"];
                    [Global showTextHud:requestResultStr view:self.view];
                    
                    
                    
                    TheLoginViewController*vc1=[[TheLoginViewController alloc] init];
                    
                    [self.navigationController pushViewController:vc1 animated:YES];
                    
                }
                
            }
            
        }
        else
        {
            [Global hideProgressHUDInternal:self.view];
            
            [Global showTextHudSub:@"连接失败" view:self.view];
        }
        
    }];
    
    
    UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
    myNewsCell *sharecell=(myNewsCell *)cell;
    
    [sharecell.dian removeFromSuperview];
    
    sharecell.name.textColor=zhonghuiColor;

    [sharecell.text setTextColor:zhonghuiColor];
    
   [sharecell.time setTextColor:zhonghuiColor];
   
    
    
}


- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    
    if (buttonIndex == 0) {
        
        
        
        TheLoginViewController*vc1=[[TheLoginViewController alloc] init];
        
        [self.navigationController pushViewController:vc1 animated:YES];
        
        
        
    }
}

- (void)showAlertWait
{
    alt = [[UIAlertView alloc] initWithTitle:@"网络不稳定哦 ！" message:@"请确认网络" delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
    
}



- (void)showAlertMessage:(NSString *)msg
{
    alt = [[UIAlertView alloc] initWithTitle:@"温馨提示" message:msg delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alt show];
    
    [self performSelector:@selector(hideAlert) withObject:nil afterDelay:1.0f];
}
- (void)hideAlert
{
    if (alt != nil)
    {
        [alt dismissWithClickedButtonIndex:0 animated:YES];
        alt = nil;
    }
}
@end
